Random Mandala Python package

Anton Antonov
Python-packages at GitHub/antononcube
November 2021

Introduction

This Python package implements the function random_mandala that generates plots (and images) of random mandalas.

The design, implementation strategy, and unit tests closely resemble the Wolfram Repository Function (WFR) RandomMandala, [AAf1].

(Another, very similar function at WFR is RandomScribble, [AAf2].)

The Bezier mandala seeds are created using the Python package bezier, [DHp1].

For detailed descriptions of Machine Learning studies that use collections of random mandalas see the articles [AA1, AA2].


Installation

To install from GitHub use the shell command:

python -m pip install git+https://github.com/antononcube/Python-packages.git#egg=RandomMandala\&subdirectory=RandomMandala

To install from PyPI:

python -m pip install RandomMandala

Details and arguments


Examples

Load the package RandomMandala, matplotlib, and PIL:

Here we generate a random mandala:

Here we generate a figure with 12 (3x4) random mandalas:

Arguments details

n_rows, n_columns

With the argument n_rows and n_columns are specified the number of rows and columns respectively in the figure object; n_rows * n_columns mandalas are generated:

connecting_function

The argument connecting_function specifies which graphics primitives to be used over the seed segment points:

With values None or "random" a random choice is made from ['line', 'fill', 'bezier', 'bezier_fill'].

radius

In single-mandala mode the argument radius specifies the radius of the seed segment and the mandala:

If the value given to radius is a list of positive numbers then multi-mandala mode is used. If radius=[r[0],...,r[k]], then for each r[i] is made a mandala with radius r[i] and the mandalas are drawn upon each other according to their radii order:

Remark: The code above used different colors for the different radii.

rotational_symmetry_order

The argument rotational_symmetry_order specifies how many copies of the seed segment comprise the mandala:

number_of_elements

The argument number_of_elements controls how may graphics elements are in the seed segment:

symmetric_seed

The argument symmetric_seed specifies should the seed segment be symmetric or not:

face_color and edge_color

The arguments face_color and edge_color take as values strings or list of strings that specify the coloring of the filled-in polygons and lines respectively:

color_mapper

The arugment color_mapper takes as values None and matplotlib.colors.Colormap objects. See the color mappers in the reference page "color example code: colormaps_reference.py". If color_mapper is specified then the arguments face_color and edge_color are ignored. Here is an example using two color mappers:


Applications

Generate a collection of images

In certain Machine Learning (ML) studies it can be useful to be able to generate large enough collections of (random) images.

In the code block below we:

Neat examples

A table of random mandalas

A table of colorzied mandals

A table of open colorized mandalas


References

Articles

[AA1] Anton Antonov, "Comparison of dimension reduction algorithms over mandala images generation", (2017), MathematicaForPrediction at WordPress.

[AA1] Anton Antonov, "Generation of Random Bethlehem Stars, (2020), MathematicaForPrediction at WordPress.

Functions

[AAf1] Anton Antonov, RandomMandala, (2019), Wolfram Function Repository.

[AAf2] Anton Antonov, RandomScribble, (2020), Wolfram Function Repository.

Packages

[DHp1] Daniel Hermes, bezier Python package, (2016), PyPy.org.